<template>
	<view>
		<view v-if="isInit" v-cloak>
			<noRecord v-if="menuInfo.list.length == 0" :info="info" v-cloak></noRecord>
			<menuBox :menuInfo="menuInfo" v-else></menuBox>
		</view>
	</view>
</template>

<script>
import menuBox from '@/wxcomponents/commonLayout/menuList';
import login from '@/libs/login.js';
import noRecord from '@/wxcomponents/commonLayout/noRecord.vue';
import { getDictName, dectList } from '@/libs/common.js';
export default {
	data() {
		return {
			isInit: false,
			info: '没有点名信息!',
			menuInfo: {
				base: {
					tit: ['课程', '节次', '班级', '操作'],
					menuProp: ['courseName', 'num', 'className', 'operation'],
					class: ''
				},
				list: []
			}
		};
	},
	async onShow() {
		this.getList();
	},
	methods: {
		async getList() {
			this.menuInfo.list = [];
			let resp = await this.$http.post({
				url: '/edu/rollCall/listAndSaveCourseByTeacher'
			});
			let dictList = await dectList('dict_lesson_begin_status'); //获取该数据字典的信息列表
			resp.result.forEach(async (item, index) => {
				//lessonBeginStatus为1 上课  2 下课  3 已下课
				let url = '';
				if (item.lessonBeginStatus == 3) {
					url = `classRollRecord?data=${item.id}&courseName=${item.courseName}&time=${item.updateTime}`;
				} else {
					url = `studentList?data=${item.id}&courseName=${item.courseName}&lessonStatus=${item.lessonBeginStatus}`;
				}
				this.menuInfo.list.push({
					url: url,
					data: item,
					courseName: this.shortStr(item.courseName, 4),
					num: item.lessonSectionShow,
					className: item.className,
					operation: await getDictName(dictList, item.lessonBeginStatus), //翻译数据字典对应的中文信息
					class: item.lessonBeginStatus != 3 ? 'btn' : 'yxk'
				});
			});
			this.isInit = true;
		}
	},
	components: {
		menuBox,
		noRecord
	}
};
</script>

<style lang="scss" scoped></style>
